//
//  HJCustomerReceptionSearchView.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/5/17.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJCustomerReceptionSearchView.h"

@interface HJCustomerReceptionSearchView()
/**
 输入框
 */
@property(nonatomic,weak)UITextField*textFieldView;
@end
@implementation HJCustomerReceptionSearchView

InitFrameM
-(void)setUI{
    WEAKSELF;
    //输入框
    UITextField*textFieldView=[[UITextField alloc]init];
    [self addSubview:textFieldView];
    textFieldView.layer.borderColor=[UIColor blackColor].CGColor;
    textFieldView.layer.borderWidth=1;
    textFieldView.placeholder=@"请输入车牌号/VIN/车主姓名/联系号码";
    self.textFieldView=textFieldView;
    [textFieldView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf);
        
        make.size.mas_equalTo(CGSizeMake(350, 35));
        make.left.mas_equalTo(weakSelf).offset(30);
    }];
    
    CGFloat btnW=80;
    CGFloat btnH=35;
    //扫描
    UIButton*scanBtn=[[UIButton alloc]init];
    [self addSubview:scanBtn];
    scanBtn.backgroundColor=[UIColor redColor];
    [scanBtn setTitle:@"扫描" forState:UIControlStateNormal];
    scanBtn.layer.cornerRadius=8;
    scanBtn.layer.masksToBounds=YES;
    [scanBtn addTarget:self action:@selector(clickScan) forControlEvents:UIControlEventTouchUpInside];
    [scanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(btnW, btnH));
        make.centerY.mas_equalTo(weakSelf);
        make.left.mas_equalTo(textFieldView.mas_right).offset(10);
    }];
    
    //查询
    UIButton*searchBtn=[[UIButton alloc]init];
    [self addSubview:searchBtn];
    searchBtn.backgroundColor=[UIColor redColor];
    [searchBtn setTitle:@"查询" forState:UIControlStateNormal];
    searchBtn.layer.cornerRadius=8;
    searchBtn.layer.masksToBounds=YES;
    [searchBtn addTarget:self action:@selector(clickSeachKey) forControlEvents:UIControlEventTouchUpInside];
    [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(btnW, btnH));
        make.centerY.mas_equalTo(weakSelf);
        make.left.mas_equalTo(scanBtn.mas_right).offset(20);
    }];
}
-(void)clickScan{
    if ([_delegate respondsToSelector:@selector(customerReceptionSearchViewClickScan:)]) {
        [_delegate customerReceptionSearchViewClickScan:self];
    }
}
-(void)setKey:(NSString *)key
{
    _key=key;
    self.textFieldView.text=key;
}
-(void)clickSeachKey{
    if ([_delegate respondsToSelector:@selector(customerReceptionSearchView:clickSearchNumber:)]) {
        [_delegate customerReceptionSearchView:self clickSearchNumber:self.textFieldView.text];
    }
}
@end
